﻿/// <reference path="Common.js" />
/// <reference path="MyString.js" />

//风格相关
var MyStyle = {
    setMouseOverStyle: function (oField, sClassName) {
        /// <summary>设置鼠标移动上去的风格样式</summary>
        /// <param name="oField" type="Object">设置样式的目标对象</param>
        /// <param name="sClassName" type="String">CSS类名，如果不传入，则自动在原来的类名上面加上_Hover</param>
        if (oField) {
            if (!sClassName && !oField.className) { return false; }
            if (!sClassName) {
                sClassName = oField.className + "_Hover";
            }
            oField.className = sClassName;
            return true;
        }
    },
    setMouseOutStyle: function (oField, sClassName) {
        /// <summary>设置鼠标移走的风格样式</summary>
        /// <param name="oField" type="Object">设置样式的目标对象</param>
        /// <param name="sClassName" type="String">CSS类名，如果不传入，则自动去掉原来的类名后缀_Hover</param>
        if (oField) {
            if (!sClassName && !oField.className.endsWith("_Hover")) { return false; }
            if (!sClassName) {
                sClassName = oField.className.leftOfLast("_Hover");
            }
            oField.className = sClassName;
            return true;
        }
    },
    setMouseClickStyle: function (oField, sClassName) {
        /// <summary>设置鼠标移点击的风格样式</summary>
        /// <param name="oField" type="Object">设置样式的目标对象</param>
        /// <param name="sClassName" type="String">CSS类名，如果不传入，则自动去掉原来的类名后缀_Click</param>
        if (oField) {
            if (!sClassName && !oField.className) { return false; }
            if (!sClassName) {
                sClassName = oField.className + "_Click";
            }
            oField.className = sClassName;
            return true;
        }
    }
};